let currentPrice = parseInt(sessionStorage.getItem("current price"),10);
let number = parseInt(sessionStorage.getItem("number"),10);
let total = currentPrice * number;

//窗口运行完毕显示订单信息
window.onload = function (){
    const goodsName = sessionStorage.getItem("goodsName");
    const goodsOPrice = sessionStorage.getItem("original price");
    const goodsImage = sessionStorage.getItem("goodImage");
    const pt = document.getElementById("pt");
    const op = document.getElementById("op");
    const cp = document.getElementById("cp");
    const pi = document.getElementById("pi");
    pt.textContent = goodsName;
    op.textContent = "原标价：￥" + goodsOPrice;
    op.style = "text-decoration: line-through;";
    cp.textContent = "实付款：￥" + total;
    pi.src = goodsImage;
}

// 确认订单，跳转到支付页面
function yes(){
    window.location.href = 'buy.html';
}

// 取消订单，保存取消订单信息
function no() {
    $.ajax({
        url:"/orders",
        type:"get",
        data:{
            type:"add",
            userId:sessionStorage.getItem("userid"),
            goodsId:sessionStorage.getItem("id"),
            unitPrice:sessionStorage.getItem("current price"),
            number:sessionStorage.getItem("number"),
            price:total,
            state:5,
        dataType:"text",
        }
    })
    window.location.href = "info.html";
}